/**
 * @author : 戚欣扬
 * @code :
 */
class Solution {
    public int minSubArrayLen(int target, int[] nums) {

        int slow  = 0;
        int minLength = Integer.MAX_VALUE;
        int sum = 0;
        for(int fast = slow ; fast <= nums.length ; fast++){
            if(sum < target && fast!=nums.length){
                sum+= nums[fast];
            }else{

                minLength = Math.min(minLength,fast-slow);
                sum-=nums[slow++];
            }

        }
        return minLength==Integer.MAX_VALUE ? 0 : minLength;
    }

    public static void main(String[] args) {
        int [] a= new int []{2,3,1,2,4,3};
        int i = new Solution().minSubArrayLen(7, a);
        System.out.println("i = " + i);
    }
}

